﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Input;
using Microsoft.Practices.Prism.Regions;
using Microsoft.Practices.ServiceLocation;
using Microsoft.Practices.Unity;
using ShellInfrastructure;
using ModuleExternalProducers.Views;
using Microsoft.Practices.Prism.Events;
using EventInfrastructure;


namespace ShopShell.ProducerCommands
{
    public class ShowProducersCommand : ICommand
    {
        [Dependency]
        public IRegionManager RegionManager { get; set; }

        [Dependency]
        public IEventAggregator EventAggregator { get; set; }

        public bool CanExecute(object parameter)
        {
            return true;
        }

        public void Execute(object parameter)
        {
            EventAggregator = ServiceLocator.Current.GetInstance<IEventAggregator>();
            RegionManager = ServiceLocator.Current.GetInstance<IRegionManager>();

            IRegion region = RegionManager.Regions[RegionNames.LeftRegionName];
            region.Activate(ServiceLocator.Current.GetInstance<IProducersView>());
            EventAggregator.GetEvent<SelectCategoryEvent>().Publish(true);
        }


        public event EventHandler CanExecuteChanged;
    }
}
